function sysAlert(param, flag, fun) {
    var div = $("<div/>").addClass("local_loading").css({
        "opacity": "0.7",
        "position": "fixed",
        "top": "0px",
        "bottom": "0px",
        "left": "0px",
        "right": "0px",
        "background-color": "#6F6F6F",
        "z-index": "100"
    }).on("click", function () {
        $(this).remove();
        $('.zheZhao').hide();
        $("#sysAlert").remove();
    });
    //$("body").children("div").wrapAll(div);
    $("body").append(div);
    var divWin = $("<table/>").css({
        "z-index": "200",
        "position": "fixed",
        "left": "15%",
        "width": "70%",
        "max-height": "200px",
        "height": "30%",
        "top": "30%",
        "background-color": "white",
        "border-radius": "10px",
        "text-align": "center",
        "font-size": "16px !important"
    }).attr("id", "sysAlert").appendTo($("body"));
    var trTitle = $("<tr/>").append($("<td/>").css({
        "height": "45px",
        "font-size": "16px !important",
        "vertical-align": "middle"
    }).text(param.title)).appendTo(divWin);
    var spanClose = $("<span/>").css({
        display: "inline-block",
        position: "absolute",
        right: "10px",
        top: "16px",
        "font-size": '13px !important'
    }).text("关闭").click(function () {
        $(".local_loading").children().unwrap();
        $(".local_loading").remove();
        $(this).parent().parent().parent().remove();
        $('.zheZhao').hide();
        if (flag == 1) {
            fun();
        }
    }).appendTo(trTitle);
    var trContent = $("<tr/>").append($("<td/>").css({
        "text-align": "center",
        "vertical-align": "middle",
        "margin": "0 20px",
        "word-wrap": "break-word",
        "word-break": "break-all",
        "cellspacing": "20px"
    }).text(param.content)).appendTo(divWin);
    $("<tr/>").appendTo(divWin);
    var html = param.html;
    if (html) {
        trContent.children("td").html(html);
    }
    if (param.okUrl) {
        var okBtn = $("<a/>").css({
            "position": "absolute",
            "width": "60px",
            "display": "inline-block",
            "text-align": "center",
            "text-decoration": "none",
            "color": "black",
            "left": "20px"
        }).text("确定");
        if (getPlatform() == "android") {
            okBtn.attr("ng-click", "go('" + getPlatform() + "','" + param.okUrl + "')")
        } else {
            okBtn.attr("href", param.okUrl);
        }
        var trBtn = $("<tr/>").append($("<td/>").css({
            "height": "40px",
            "vertical-align": "middle",
            "border-top": "1px solid green",
            "position": "relative"
        }).append(okBtn).append($("<a/>").css({
            "position": "absolute",
            "width": "60px",
            "display": "inline-block",
            "text-align": "center",
            "text-decoration": "none",
            "color": "black",
            "right": "20px"
        }).text("取消").click(function () {
            $(".local_loading").children().unwrap();
            $(this).parent().parent().parent().parent().remove();
        }))).appendTo(divWin);
    }
}
function sysMsg(param, fun, fun2) {
    var div = $("<div/>").addClass("local_loading").css({
        "opacity": "0.7",
        "position": "fixed",
        "top": "0px",
        "bottom": "0px",
        "left": "0px",
        "right": "0px",
        "background-color": "#6F6F6F",
        "z-index": "180"
    }).on("click", function () {
        // $(this).remove();
        // $('.zheZhao').hide();
        // $("#sysAlert").remove();
    });
    $("body").append(div);
    var divWin = $("<table/>").css({
        "z-index": "200",
        "position": "fixed",
        "left": "15%",
        "width": "70%",
        "max-height": "200px",
        "height": "30%",
        "top": "30%",
        "background-color": "white",
        "border-radius": "10px",
        "text-align": "center",
        "font-size": "16px"
    }).attr("id", "sysAlert").appendTo($("body"));
    var trTitle = $("<tr/>").append($("<td/>").css({
        "height": "45px",
        "font-size": "16px",
        "vertical-align": "middle"
    }).text(param.title)).appendTo(divWin);
    var trContent = $("<tr/>").append($("<td/>").css({
        "text-align": "center",
        "vertical-align": "middle",
        "margin": "0 20px",
        "word-wrap": "break-word",
        "word-break": "break-all",
        "cellspacing": "20px"
    }).text(param.content)).appendTo(divWin);
    $("<tr/>").appendTo(divWin);
    var html = param.html;
    if (html) {
        trContent.children("td").html(html);
    }
    var okBtn = $("<span/>").css({
        "position": "absolute",
        "width": "70px",
        "display": "inline-block",
        "text-align": "center",
        "text-decoration": "none",
        "color": "black",
        "left": "20px",
        "padding": "10px",
        "top": "0px",
        "line-height": "30px"
    }).text(param.okStr ? param.okStr : "确定").on("click", function () {
        $(this).parent().parent().parent().parent().remove();
        $(".local_loading").remove();
        $('.zheZhao').hide();
        if (fun) {
            fun();
        }
    });
    var lineSpan = $("<span/>").css({
        "height": "41px",
        "width": "1px",
        "position": "absolute",
        "left": "50%",
        "top": "0px",
        "background-color": "#cccccc"
    })
    var trBtn = $("<tr/>").append($("<td/>").css({
        "height": "40px",
        "vertical-align": "middle",
        "border-top": "1px solid #cccccc",
        "position": "relative"
    }).append(okBtn).append(lineSpan).append($("<span/>").css({
        "position": "absolute",
        "width": "60px",
        "display": "inline-block",
        "text-align": "center",
        "text-decoration": "none",
        "color": "black",
        "right": "20px",
        "padding": "10px",
        "top": "0px",
        "line-height": "30px"
    }).text(param.canStr ? param.canStr : "取消").click(function () {
        $(this).parent().parent().parent().parent().remove();
        $(".local_loading").remove();
        $('.zheZhao').hide();
        if (fun2) {
            fun2();
        }
    }))).appendTo(divWin);

}
function sysToast(str, time) {
    var divWin = $("<table/>").css({
        "z-index": "200",
        "position": "fixed",
        "left": "15%",
        "width": "70%",
        "max-height": "200px",
        "height": "10%",
        "top": "44%",
        "opacity": "0.5",
        "background-color": "black",
        "border-radius": "3px",
        "text-align": "center"
    }).attr("id", "sysAlert").appendTo($("body"));
    var trContent = $("<tr/>").append($("<td/>").css({
        "text-align": "center",
        "vertical-align": "middle",
        "margin": "0 20px",
        "color": "#e1d5d5",
        "font-size": "15px",
        "word-wrap": "break-word",
        "word-break": "break-all",
        "cellspacing": "20px"
    }).text(str)).appendTo(divWin);
    setTimeout(function () {
        $("#sysAlert").remove();
    }, time ? time : 2000);
}

Date.prototype.format = function (format) {
    var date = {
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "h+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "q+": Math.floor((this.getMonth() + 3) / 3),
        "S+": this.getMilliseconds()
    };
    if (/(y+)/i.test(format)) {
        format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
    }
    for (var k in date) {
        if (new RegExp("(" + k + ")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length == 1
                ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
        }
    }
    return format;
}
function addDate(date, days) {
    if (days == undefined || days == '') {
        days = 1;
    }
    var date = new Date(date);
    date.setDate(date.getDate() + days);
    return date;
}
function addHour(dateStr, hour) {
    var date;
    if (dateStr)
        date = new Date(dateStr);
    else date = new Date();
    date.setHours(date.getHours() + hour);
    return date;
}
function subTime(time) {
    var obj = {};
    var date = new Date();
    var date1 = new Date(time);
    var num = date1.getTime() - date.getTime();
    obj.hour = Math.floor(
        num / (60 * 60 * 1000));
    obj.min = Math.floor(num % (60 * 60 * 1000) / (60 * 1000));
    return obj;
}
function timeCha(time, time1) {
    var date = new Date(time);
    var date1 = new Date(time1);
    var num = date1.getTime() - date.getTime();
    return num;
}
function checkPhone(phone) {
    var reg = /^1[3|4|5|7|8][0-9]{9}$/; //验证规则
    var flag = reg.test(phone); //true
    return flag;
}
function Rad(d) {
    return d * Math.PI / 180.0;//经纬度转换成三角函数中度分表形式。
}
//计算距离，参数分别为第一点的纬度，经度；第二点的纬度，经度
function GetDistance(lat1, lng1, lat2, lng2) {

    var radLat1 = Rad(lat1);
    var radLat2 = Rad(lat2);
    var a = radLat1 - radLat2;
    var b = Rad(lng1) - Rad(lng2);
    var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
            Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
    s = s * 6378.137;// EARTH_RADIUS;
    s = Math.round(s * 10000) / 10000; //输出为公里
    //s=s.toFixed(4);
    return s;
}
function sysAlertMsg(content, btn, fun) {
    var div = $("<div/>").addClass("local_loading").css({
        "opacity": "0.5",
        "position": "fixed",
        "top": "0px",
        "bottom": "0px",
        "left": "0px",
        "right": "0px",
        "background-color": "#6F6F6F",
        "z-index": "100"
    }).on("click", function () {
        $(this).remove();
        $('.zheZhao').hide();
        $("#sysAlert").remove();
    });
    $("body").append(div);
    var divWin = $("<table/>").css({
        "z-index": "200",
        "position": "fixed",
        "left": "15%",
        "width": "70%",
        "max-height": "200px",
        "height": "23%",
        "top": "35%",
        "background-color": "#f2f2f2",
        "border-radius": "12px",
        "text-align": "center",
        "font-size": "14px"
    }).attr("id", "sysAlert").appendTo($("body"));
    var trContent = $("<tr/>").css("height", "65%").append($("<td/>").css({
        "text-align": "center",
        "vertical-align": "middle",
        "margin": "0 20px",
        "word-wrap": "break-word",
        "word-break": "break-all",
        "cellspacing": "20px",
        "border-bottom": "1px solid #dbdbdb",
        "font-size": "15px",
        "font-weight": "700"
    }).text(content)).appendTo(divWin);
    var trContentDiv = $("<tr/>").append($("<td/>").css({
        "text-align": "center",
        "vertical-align": "middle",
        "margin": "0 20px",
        "word-wrap": "break-word",
        "word-break": "break-all",
        "cellspacing": "20px",
        "color": "#2ab2f9",
        "font-weight": "500"
    }).text(btn ? btn : "确定")).on("click", function () {
        if (fun) {
            fun();
        } else {
            $(".local_loading").remove();
            $('.zheZhao').hide();
            $("#sysAlert").remove();
        }
    }).appendTo(divWin);
}